package io.gitee.mingbaobaba.apijson.querycondition.query.conditions;

import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

/**
 * <p>分组片段</p>
 */
class GroupSegment implements DslSegment {

    @Override
    public void apply(AbstractBaseWrapper<?, ?, ?> wrapper) {
        if (CollectionUtils.isEmpty(wrapper.groupList)) {
            return;
        }
        wrapper.apiJsonParams.put(EnumApiJson.GROUP.getCode(), SegmentJoiner.join(",", wrapper.groupList));
        if (StringUtils.isNotBlank(wrapper.havingFunc)) {
            wrapper.apiJsonParams.put(EnumApiJson.HAVING.getCode(), wrapper.havingFunc);
        }
    }
}

